package com.ktjy.factory;

import com.ktjy.dao.NewsDao;
import com.ktjy.dao.impl.NewsBlackDaoImpl;
import com.ktjy.dao.impl.NewsDaoImpl;
import com.ktjy.dao.impl.NewsRedDaoImpl;

/**
 * 生产NewsDao的工厂
 */
public class NewsDaoFactory {

    public static NewsDao getNewsDao(String key) {
        // return new NewsDaoImpl();
        switch (key) {
            case "1":
                return new NewsDaoImpl();
            case "2":
                return new NewsBlackDaoImpl();
            case "3":
                return new NewsRedDaoImpl();
            default:
                throw new RuntimeException("无效的数据库类型：" + key);
        }
    }
}
